<?php
class Application_Model_QcmMapper{
	protected $_dbTable;

	public function setDbTable($dbTable){
		if (is_string($dbTable)) {
			$dbTable = new $dbTable();
		}
		if (!$dbTable instanceof Zend_Db_Table_Abstract) {
			throw new Exception('Invalid table data gateway provided');
		}
		$this->_dbTable = $dbTable;
		return $this;
	}

	public function getDbTable(){
		if (null === $this->_dbTable) {
			$this->setDbTable('Application_Model_DbTable_Qcm');
		}
		return $this->_dbTable;
	}
	public function fetchAllByGroup($section,$annee,$groupe){
		$resultSet = $this->getDbTable()->fetchAllByGroup($section,$annee,$groupe);
		$entries = array();
		foreach($resultSet as $row){
			$entry = new Application_Model_Qcm();
			$entry	->setId($row->id)
					->setTitre($row->titre)
					->setDescription($row->description);
			$entries[] = $entry;
		}
		return $entries;
	}
}